package com.up.upzl.biz.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.up.upzl.biz.domain.ShopBusinessType;
import com.up.upzl.biz.service.ShopBusinessTypeService;

/**
 * 商铺业态控制器
 * 
 * @author joker
 *
 */
@Controller
@RequestMapping("shopBusinessType")
public class ShopBusinessTypeController {

	@Autowired
	private ShopBusinessTypeService shopBusinessTypeService;

	/**
	 * 查找二级业态
	 */
	@GetMapping("findSon")
	public @ResponseBody List<ShopBusinessType> findSon(@Param("pid") Long pid) {
		if (pid == null) {
			return null;
		}
		List<ShopBusinessType> list = shopBusinessTypeService.findByPid(pid);
		if (list == null) {
			return null;
		}
		return list;
	}

	/**
	 * 查找一级业态
	 */
	@GetMapping("findParent")
	public @ResponseBody List<ShopBusinessType> findParent() {
		List<ShopBusinessType> list = shopBusinessTypeService.findByPid(null);
		if (list == null) {
			return null;
		}
		return list;
	}
	
	/**
	 * 通过Id查询
	 * @return
	 */
	@GetMapping("findById")
	public @ResponseBody List<ShopBusinessType> findById() {
		List<ShopBusinessType> list = shopBusinessTypeService.findByPid(null);
		if (list == null) {
			return null;
		}
		return list;
	}

}
